Skip to content

Use GNUInstallDirs with CACHE variables for install destinations (fixes #1120)#1152

Merged
facontidavide merged 1 commit into
BehaviorTree:masterfrom
wooksong:fix/gnuinstalldirs-cache-install-destinations
Jul 6, 2026
Merged

Use GNUInstallDirs with CACHE variables for install destinations (fixes #1120)#1152
facontidavide merged 1 commit into
BehaviorTree:masterfrom
wooksong:fix/gnuinstalldirs-cache-install-destinations

Conversation

@wooksong

Copy link
Copy Markdown
Contributor

Fixes #1120

Problem

The install destination variables use plain set(), which prevents overriding them from the CMake command line. This blocks Debian/Ubuntu packagers from installing to multiarch directories (e.g. lib/x86_64-linux-gnu).

Solution

include(GNUInstallDirs) with set(... CACHE STRING ...) defaults.

Two override mechanisms:

  • -DBTCPP_LIB_DESTINATION=lib/x86_64-linux-gnu (project-specific)
  • -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu (system-wide, standard)

API / ABI / Backward compatibility

No API or ABI changes: this is a build system change only.

  • ROS2/ament builds: unaffected. ament_build.cmake only calls mark_as_advanced() on these variables; ament handles installation separately.
  • Standard Linux: CMAKE_INSTALL_LIBDIR resolves to lib: no change from current behavior.
  • Existing -DBTCPP_LIB_DESTINATION=... usage: still works, CACHE variable takes precedence.

Pre-commit / clang-tidy

Not applicable: this PR changes only CMakeLists.txt. The clang-format and clang-tidy hooks target .cpp/.hpp/.h files only.

Verified

Check Result
Configure (default) BTCPP_LIB_DESTINATION: lib
Build 100% (45 TUs, no warnings)
Install (default) lib/libbehaviortree_cpp.so
Override -DBTCPP_LIB_DESTINATION=custom/lib -> custom/lib/libbehaviortree_cpp.so

Replace hardcoded `set()` with `set(... CACHE STRING ...)` defaulting to
GNUInstallDirs values. This allows Debian/Ubuntu packagers to override
installation directories (e.g. `-DBTCPP_LIB_DESTINATION=lib/x86_64-linux-gnu`)
for multiarch support while preserving backward compatibility.

Fixes BehaviorTree#1120
@wooksong wooksong force-pushed the fix/gnuinstalldirs-cache-install-destinations branch from 2897351 to c178acb Compare June 26, 2026 14:38
@facontidavide facontidavide merged commit 4c189d2 into BehaviorTree:master Jul 6, 2026
17 of 27 checks passed
@wooksong wooksong deleted the fix/gnuinstalldirs-cache-install-destinations branch July 8, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow overriding installation directories to support multiarch packaging (Debian/Ubuntu) and standalone usage

2 participants